#include "State.h"
#include "LightsSystem.h"

State::State(int time)
:_time(time)
,_leftTime(time)
{
}
State::~State(){
}

void State::start(){
    on();
}
void State::stop(){
    off();
}
void State::onTimeout(LightsSystem * ls){
}

void State::onTimeout(LightsSystem * ls, State * nextState){
    if(isEnd()){
        off();
        reset();
        changeState(ls, nextState);
        //nextState->on();
    }
    else{
        elapse();
        on();
    }
}
void State::changeState(LightsSystem * ls, State * state){
    ls->changeState(state);
}
